@extends('admin.public')

@section('content')
    <div class="col-md-12">
        <section class="panel panel-default">
            <header class="panel-heading">
                {{ $frame['title'] }}
            </header>
            <div class="row wrapper">
                <div class="col-sm-5 m-b-xs">
                    <form action="" method="get">
                        <select class="input-sm form-control input-s-sm inline v-middle" name="level">
                            @foreach( $levels as $level )
                                <option value="{{ $level['id'] }}" {{ $append['level'] == $level['id']?'selected':'' }}>{{ $level['name'] }}</option>
                            @endforeach
                        </select>
                        <button class="btn btn-sm btn-default">查询</button>
                    </form>
                </div>
                <div class="col-sm-4 m-b-xs">
                    <div class="btn-group">
                        <a class="btn btn-sm btn-default"
                           href="{{ route('admin.user.index') }}">
                            全部
                        </a>
                        <a class="btn btn-sm btn-default {{ $append['status']==1?'active':'' }}"
                           href="{{ route('admin.user.index') }}?status=1">
                            活跃会员
                        </a>
                        <a class="btn btn-sm btn-default {{ $append['status']=='0'?'active':'' }}"
                           href="{{ route('admin.user.index') }}?status=0">
                            封停会员
                        </a>
                    </div>
                </div>
                <div class="col-sm-3">
                    <form action="" method="get">
                        <div class="input-group">
                            <input type="text" class="input-sm form-control" placeholder="请输入信息名称" name="search"
                                   value="{{ $append['search'] }}">
                            <span class="input-group-btn">
                                <button class="btn btn-sm btn-default">搜索</button>
                            </span>
                        </div>
                    </form>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped b-t b-light">
                    <thead>
                    <tr>
                        <th style="width:20px;">
                            <label class="checkbox m-n i-checks"><input type="checkbox"><i></i></label></th>
                        <th class="col-md-4">会员名</th>
                        <th class="col-md-2">会员等级</th>
                        <th class="col-md-2">注册时间</th>
                        <th class="col-md-2">编辑时间</th>
                        <th class="col-md-2">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @if( $users->count() > 0 )
                        @foreach( $users as $user )
                            <tr>
                                <td><label class="checkbox m-n i-checks">
                                        <input type="checkbox" name="post[]" value="{{ $user->id }}"><i></i></label>
                                </td>
                                <td class="col-md-4">{{ $user->name }}</td>
                                <td class="col-md-2">
                                    @if(!empty($user->level_logo))
                                        <img src="{{ $user->level_logo }}" alt="{{ $user->level_name }}">
                                    @endif
                                    {{ $user->level_name }}
                                </td>
                                <td class="col-md-2">{{ $user->created_at }}</td>
                                <td class="col-md-2">{{ $user->updated_at }}</td>
                                <td class="col-md-2">
                                    <a href="{{ route('admin.user.edit',$user['id']) }}" class="btn btn-xs btn-default">编辑</a>
                                    <a href="{{ route('admin.user.delete',$user['id']) }}"
                                       class="btn btn-xs btn-default">删除</a>
                                </td>
                            </tr>
                        @endforeach
                    @else
                        <tr>
                            <td colspan="6" align="center">
                                暂无相关信息!
                            </td>
                        </tr>
                    @endif
                    </tbody>
                </table>
            </div>
            <footer class="panel-footer">
                <div class="row">
                    <div class="col-sm-5 hidden-xs">
                        <form action="" method="get">
                            <select class="input-sm form-control input-s-sm inline v-middle" name="level">
                                @foreach( $levels as $level )
                                    <option value="{{ $level['id'] }}" {{ $append['level'] == $level['id']?'selected':'' }}>{{ $level['name'] }}</option>
                                @endforeach
                            </select>
                            <button class="btn btn-sm btn-default">查询</button>
                        </form>
                    </div>
                    <div class="col-sm-3 text-center">
                        <small class="text-muted inline m-t-sm m-b-sm">显示 {{ $users->count() }} 条
                            共 {{ $users->total() }} 条
                        </small>
                    </div>
                    <div class="col-sm-4 text-right text-center-xs">
                        @if(!empty($append))
                            {!! $users->appends($append)->links() !!}
                        @else
                            {!! $users->links() !!}
                        @endif
                    </div>
                </div>
            </footer>
        </section>
    </div>
@endsection

@section('css')
@endsection

@section('js')
    <script>
        $('button[name="active"]').click(function () {
            var info = [];
            $('input[name="post[]"]:checked').each(function () {
                info.push($(this).val());
            })
            $('input[name="info_id"]').val(info);
        })
    </script>
@endsection